package cn.lingyangwl.agile.model.module.config.param;

import cn.lingyangwl.agile.model.constants.ValidationCons;
import cn.lingyangwl.agile.model.enums.ConfigKeyEnum;
import cn.lingyangwl.framework.data.mate.annotations.FieldSensitive;
import cn.lingyangwl.framework.data.mate.fieldsensitive.enums.StrategyType;
import com.alibaba.fastjson2.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotEmpty;

/**
 * gitee 开源社区配置
 *
 * @author shenguangyang
 */
@Getter
@Setter
@Component
public class GiteeParam extends BaseConfigParam<GiteeParam> {
    /**
     * 客户端id
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    private String clientId;

    /**
     * 客户端密钥
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    @FieldSensitive(strategy = StrategyType.RESERVE_4)
    private String clientSecret;

    /**
     * 回调地址
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    private String callbackUrl;

    /**
     * 私人令牌, 用于调用 gitee open api
     */
    @NotEmpty(message = ValidationCons.NOT_EMPTY)
    @FieldSensitive(strategy = StrategyType.RESERVE_4)
    private String accessToken;

    @Override
    protected GiteeParam jsonToObject(String json) {
        return JSON.parseObject(json, GiteeParam.class);
    }

    @Override
    public ConfigKeyEnum configKey() {
        return ConfigKeyEnum.GITEE;
    }
}
